package chapter1_7_interrupt;

/**
 * @author huayuhao
 * @date 2020/12/15 18:28
 */
public class Interrupt3Test {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            for (; ; ) {

            }
        });

        thread.start();

        // 设置中断标志
        thread.interrupt();

        // 获取中断标志
        System.out.println("IsInterrupted : " + thread.isInterrupted());
        // 获取中断标志并重置[当前线程, 此处是main] false
        System.out.println("IsInterrupted : " + thread.interrupted());
        // 获取中断标志并重置[当前线程, 此处是main] false
        System.out.println("IsInterrupted : " + Thread.interrupted());
        // 获取中断标志
        System.out.println("IsInterrupted : " + thread.isInterrupted());

        //thread.join();

        System.out.println("main over !");
    }
}
